Hi everyone,
I have been trying to program a trailing stop entry order activated by a mouse click.
I have found how to program an entry stop order with a mouse click, my problem is that I have no idea how to make that stop order trail the candles. So Let us say price is rising, and I would like the stop order to trail the low of each rising candle so that as soon as price touches the low of last candle then the stop order becomes a market order. It is a very simple entry,just don't know how to program it. Any help would be much appreciated.Here is my code
[ProcessMouseEvents = true];
[IntrabarOrderGeneration = true];
if (MouseClickCtrlPressed and not MouseClickShiftPressed) and (MarketPosition=0)then
sellshort 1 Contracts Next Bar at low[1] stop ;
thank you
Help with mouse activated trailing entry order
Re: Help with mouse activated trailing entry order
Don't know if relevant but, instead of a mouse click for your stop, maybe you could look for a a bar to touch a trend line.Hi everyone,
I have been trying to program a trailing stop entry order activated by a mouse click.
I have found how to program an entry stop order with a mouse click, my problem is that I have no idea how to make that stop order trail the candles. So Let us say price is rising, and I would like the stop order to trail the low of each rising candle so that as soon as price touches the low of last candle then the stop order becomes a market order. It is a very simple entry,just don't know how to program it. Any help would be much appreciated.Here is my code
[ProcessMouseEvents = true];
[IntrabarOrderGeneration = true];
if (MouseClickCtrlPressed and not MouseClickShiftPressed) and (MarketPosition=0)then
sellshort 1 Contracts Next Bar at low[1] stop ;
thank you
I never coded for that, but I know that someone did publish code to trade using a trend line. Not sure, but it may be even incorporated in MC.
Manually move your trendline to the position where you want your stop to be triggered.
Martin
Re: Help with mouse activated trailing entry order
Code: Select all
// By Massimo Rizzi 29.09.2015
//
// Just an idea for a semi-discretionary trading, based on a custom entry condition
//
// You can input the entry condition, the quantity of shares to trade,
// and the offset position of the start button on the chart.
//
// With shift+mouse click on the text button you can toggle from paused to active mode for the entry.
//
// This is just a starting point for your trading fantasy ...
//
// Not yet tested in realtime, let me know if it works correctly
[ProcessMouseEvents = True];
[IntrabarOrderGeneration = True];
[RecoverDrawings = False];
Inputs:
vLECondition( L < Low[1] ), // Long Enter condition
vQuantity(1), // Input Quantity of Shares to Trade
vXOffset(0.1), // Offset % x from low-left sx angle
vYOffset(0.05), // Offset % y from low-left sx angle
vEndSessionTime_s(173600); // EOD Time for closing open position
Vars:
recalcpersist vValue1(0), // id button n1
recalcpersist vMostLeftDateTime(0),
recalcpersist vMostRightDateTime(0),
recalcpersist vHighestDispValue(0),
recalcpersist vLowestDispValue(0),
recalcpersist vRangeDateTime(0),
recalcpersist vMinMove(1), // Movimento minimo scala prezzi
recalcpersist vX(0), // coordinate x buttons
recalcpersist vY(0), // coordinate y punto inferiore (click mouse)
recalcpersist vY1(0), // coordinate y button 1
recalcpersist vCounter1(0); // counter associato button 1
//
//
if LastBarOnChart then begin
//
// If MouseClickShiftPressed ...
//
if MouseClickShiftPressed then begin
// Checks for MouseClick on TextBoxes and updates vCounters
if MC_Text_GetActive=vValue1 then begin
vCounter1=vCounter1+1;
if vCounter1>1 then vCounter1=0;
end;
end; // if MouseClickShiftPressed
//
// Gets DateTime MostLeft and MostRight
// and Highest and Lowest price displayed on the chart.
//
vMostLeftDateTime = GetAppInfo(aiLeftDispDateTime);
vMostRightDateTime = GetAppInfo(aiRightDispDateTime);
vHighestDispValue = GetAppInfo(aiHighestDispValue);
vLowestDispValue = GetAppInfo(aiLowestDispValue);
vMinMove = (vHighestDispValue-vLowestDispValue)/100;
//
// Calculates new X e Y buttons coordinates
//
vX = vMostLeftDateTime + (vMostRightDateTime - vMostLeftDateTime) * vXOffset;
vY = vLowestDispValue + (vHighestDispValue-vLowestDispValue) * vYOffset;
vY1= vY+0 * vMinMove;
Once begin
//
// Creates buttons on the chart
//
vValue1=Text_New_Dt(vX, vY1,"PROVA1");
end; // once
//
// Formats and Redraws Button1
text_setborder(vValue1,TRUE);
text_setColor(vValue1,blue);
if vCounter1=0 then text_setBGColor(vValue1,red)
else if vCounter1=1 then text_setBGColor(vValue1,green);
if vCounter1=0 then begin
text_setstring(vValue1,"PAUSED: Custom LE");
end else if vCounter1=1 then begin
text_setstring(vValue1,"ACTIVE: Custom LE");
end;
text_SetStyle(vValue1,0,1);
//text_lock(vValue1,TRUE);
Text_SetLocation_DT(vValue1,vX,vY1);
//
// Trading Routine
//
If vCounter1=1 and vLECondition then buy vQuantity shares next bar at market;
end;