ramaParticipant
Senior
I am using the following code which is from the pro real time another post.
I want to quit my system once it is moved break even.
I have added the quit code it works sometime and sometimes not.
just i want to make sure breakeven is set before quit if breakevel level is reached
*****************
DEFPARAM CumulateOrders = False
buy .2 contract at low[3]+2 stop
set stop loss 45
startBreakeven = 11 //how much pips/points in gain to activate the breakeven function?
PointsToKeep = 1 //how much pips/points to keep in profit above of below our entry price when the breakeven is activated (beware of spread)
startBreakeven1 = 11.5
//reset the breakevenLevel when no trade are on market
IF NOT ONMARKET THEN
breakevenLevel=0
ENDIF
// --- BUY SIDE ---
//test if the price have moved favourably of "startBreakeven" points already
IF LONGONMARKET AND close-tradeprice>=startBreakeven*pipsize THEN
//calculate the breakevenLevel
breakevenLevel = tradeprice+PointsToKeep*pipsize
ENDIF
//place the new stop orders on market at breakevenLevel
IF longonmarket and breakevenLevel>0 THEN
SELL AT breakevenLevel STOP
if close-tradeprice>=startBreakeven1*pipsize then
quit
endif
ENDIF
IF shortONMARKET AND tradeprice-close>=startBreakeven*pipsize THEN
//calculate the breakevenLevel
breakevenLevel = tradeprice-PointsToKeep*pipsize
ENDIF
//place the new stop orders on market at breakevenLevel
IF breakevenLevel>0 and shortonmarket then
exitshort AT breakevenLevel STOP
if tradeprice-close>=startBreakeven1*pipsize then
quit
endif
ENDIF
ramaParticipant
Senior
I will be using when trading system is stopped my order will remain open the idea , moved to breakeven and avoid any loss when it is in profit
Give your topic a meaningful title. Describe your question or your subject in your title. Do not use meaningless titles such as ‘Coding Help Needed’ (code help in your case).
Thank you 🙂
************************************
Try adding:
GraphOnPrice breakevenLevel coloured(128,0,0,255) as "BreakEven"
GraphOnPrice (close-tradeprice) coloured(0,255,0,255) as "LongPROFIT"
GraphOnPrice (tradeprice-close) coloured(0,0,255,255) as "ShortPROFIT"
at the end of your code to monitor, on the price chart, the three values retained each bar.
ramaParticipant
Senior
My code works fine as long I use no quit function
I wan to quit once order is moved to break even