How to plot a MaxLoss Stop( Not a Trailing stop ) on the chart?

Hello!
I want to plot a MaxLoss Stop on the chart but after 3+ hours searching, I still can't get it done. End up here to get help. Please help me!:sob:
This is my code:

Buy = Cross(MA(C, 3), MA(C, 55);
Sell = Cross(MA(C, 55), MA(C, 3);

//Trailing Stop:
AtrTrail = (Optimize("AtrTrail", 6.5, 4, 10, 0.1) * ATR(10));
ApplyStop(stopTypeTrailing, stopModePoint, TrailAtr, 2, True, 1, 0, -1, 0);

// MaxLoss Stop:
MaxStop = Optimize("MaxStopx", 5.5, 1, 30, 0.5);
ApplyStop(stopTypeLoss, stopModePercent, MaxStop, 1, False, 0, 0, -1, 0);

Equity( 1, 0 ); 
InTrade = Flip( Buy, Sell );
SetOption("EveryBarNullCheck", True );

// Make the Trailing Stop become a line and plot it on the chart:
TrailLine = IIf(InTrade, HighestSince( Buy, High) - TrailAtr), Null); 
Plot( TrailLine, "TrailLine", colorRed )

// Now How to make the MaxLoss Stop become a line and plot it on the chart:
// ??? Please Help!
1 Like

@yescgh if I understand your question you just want to plot the Max stop loss, "Not a Trailing Stop". So you do NOT want the stop level to change (i.e. not to "trail")?

Perhaps something like this?

StopLevel = Param( "Max stop %", 3, 0.1, 10, 0.1 );

SetTradeDelays( 0, 0, 0, 0 );

Buy = Cross( MA( C, 3 ), MA( C, 55 ) );
Sell = Cross( MA( C, 55 ), MA( C, 3 ) );
BuyPrice = ValueWhen( Buy, C );
ApplyStop( stopTypeLoss , stopModePercent, StopLevel, True );

Equity( 1, 0 ); // evaluate stops, all quotes

InTrade = Flip( Buy, Sell );

SetOption( "EveryBarNullCheck", True );
stopline = IIf( InTrade, BuyPrice * ( 1 - 0.01 * StopLevel ), Null );

PlotShapes( Buy*shapeUpArrow, colorGreen, 0, Low );
PlotShapes( Sell*shapeDownArrow, colorRed, 0, High );

Plot( Close, "Price", colorAqua, styleBar );
Plot( stopline, "Max stop line", colorRed, styleThick );

image

5 Likes

Thank you, Larry! Thank you very much!
This is exactly what I need. The problem is solved.
Thank you for you help!