What is the difference between using SetStopLoss
or adding code like:
Code: Select all
condition1 = CurrentPrice <= EntryPrice - StopLoss;
if MarketPosition > 0 and condition1
then begin
sell this bar ;
end;
Code: Select all
condition1 = CurrentPrice <= EntryPrice - StopLoss;
if MarketPosition > 0 and condition1
then begin
sell this bar ;
end;
SetStopLoss is a Global Exit order.Hello,
What is the difference between using SetStopLoss
or adding code like:and what's the better thing to use?Code: Select all
condition1 = CurrentPrice <= EntryPrice - StopLoss;
if MarketPosition > 0 and condition1
then begin
sell this bar ;
end;
If I was programming this, I would use the code that specifically sets the stop order (using a designated price level) vs. the SetStopLevel code, because then I have a greater insight into how the order is being calculated and placed.
As I read it, FuryTrader means that he uses the "submit stop orders"-code instead of using the build in SetStopLoss (which is also what I do, because of the same reasons FuryTrader mentions).I did not really understand.
You meant using the SetStopLoss function into my code is better than
1. using the SetStoploss signal into my startegy
2. coding the stop in the code like I paste in my first msg
?
Code: Select all
Variables: maFast(0), maSlow(0);
maFast = XAverage(Close, 5);
maSlow = XAverage(Close, 15);
SetStopPosition;
if maFast crosses over maSlow then begin
Buy("LE") 1 contract next bar at market;
end;
if maFast crosses under maSlow then begin
SellShort("SE") 1 contract next bar at market;
end;
SetStopLoss(500); // Exit the trade is total loss is 500 dollar or more.
Code: Select all
Variables: maFast(0), maSlow(0), maxLoss(0);
maFast = XAverage(Close, 5);
maSlow = XAverage(Close, 15);
maxLoss = 500 / BigPointValue;
// Enter long
if maFast crosses over maSlow then begin
Buy("LE") 1 contract next bar at market;
end;
// Submit stop orders for long position
if MarketPosition = 1 then begin
Sell("StopXL") next bar at (EntryPrice(0) - maxLoss) stop;
end;
// Enter short
if maFast crosses under maSlow then begin
SellShort("SE") 1 contract next bar at market;
end;
// Submit stop orders for short position
if MarketPosition = -1 then begin
BuyToCover("StopXS") next bar at (EntryPrice(0) + maxLoss) stop;
end;
As far as I know, yes - but only the positions on that chart. Btw, the build in stop loss signals ("Stop Loss LX" and "Stop Loss SX") do exactly that (see the code of these signals to see how they work).An other question about the SetStopLoos function.
When calling the function, does it applies to all positions in my strategies?
I don't know how that might work out.If i have 2 different signals into my chart, and each one has a different StopLoss.
Is that Ok?
The difference is that SetStopLoss, etc. are managed by the MC internal trading engine; your own code is managed by the MC program making passes of your code. In general, if you can use SetStopLoss, SetBreakEven, etc., it is better to use them. But if you want to calculate something like rachet stops, then use the word STOP, which will execute an exit prior to end of bar when your stop conditions are met. Caveat: at some brokers, if the stop does not reside on their server, then it is possible that, particularly in a fast market if your computer lags, if the market has moved to below your stop price before your stop order is received at the exchange, then your stop order will be rejected by the exchange and you do not have a stop order after all. That would be about the only reason I can think of to use IntraBarOrderGeneration and a MARKET order as a stop (which I had to do briefly in past).Thanks Josh
I thought FuryTrader said that using the function was better that self code. So I changed my code to check it.
But if it has to be the same limit for all my signals it wont't be good enough for me.
I ll change it back.
If I can't - If I need different stoploss for different signal in my chart, is it a good reason?if you can use SetStopLoss, SetBreakEven, etc., it is better to use them
You meantthen use the word STOP
Code: Select all
Buy/sell market at Stop
Code: Select all
If MarketPosition = 1 then
begin
Sell ("LX Hard") CurrentContracts Contracts next bar YourDefinedStop STOP ;
end ;
Code: Select all
Inputs:BE_Profit_Points(2) ;
Var: ProfitFloorAmt(BE_Profit_Points * BigPointValue),
if MarketPosition <> 0 then SetBreakEven(ProfitFloorAmt);
is that it gives you greater flexibility when programming.SELL NEXT BAR AT ENTRYPRICE - 10 STOP;
Based on uncertainty surrounding how how SetStopLoss actually works in MultiCharts discussed in this thread:The difference is that SetStopLoss, etc. are managed by the MC internal trading engine; your own code is managed by the MC program making passes of your code. In general, if you can use SetStopLoss, SetBreakEven, etc., it is better to use them. But if you want to calculate something like rachet stops, then use the word STOP, which will execute an exit prior to end of bar when your stop conditions are met. Caveat: at some brokers, if the stop does not reside on their server, then it is possible that, particularly in a fast market if your computer lags, if the market has moved to below your stop price before your stop order is received at the exchange, then your stop order will be rejected by the exchange and you do not have a stop order after all. That would be about the only reason I can think of to use IntraBarOrderGeneration and a MARKET order as a stop (which I had to do briefly in past).
Without seeing your code, the problem is still undetermined.Based on uncertainty surrounding how how SetStopLoss actually works in MultiCharts discussed in this thread:The difference is that SetStopLoss, etc. are managed by the MC internal trading engine; your own code is managed by the MC program making passes of your code. In general, if you can use SetStopLoss, SetBreakEven, etc., it is better to use them. But if you want to calculate something like rachet stops, then use the word STOP, which will execute an exit prior to end of bar when your stop conditions are met. Caveat: at some brokers, if the stop does not reside on their server, then it is possible that, particularly in a fast market if your computer lags, if the market has moved to below your stop price before your stop order is received at the exchange, then your stop order will be rejected by the exchange and you do not have a stop order after all. That would be about the only reason I can think of to use IntraBarOrderGeneration and a MARKET order as a stop (which I had to do briefly in past).
viewtopic.php?f=1&t=9715
I WITHDRAW my comment regarding MultiCharts stops words SetStopLoss, etc. that: "...if you can use SetStopLoss, SetBreakEven, etc., it is better to use them."
SetStopLoss does not work on an Entry bar for me without code being set to [IntraBarOrderGeneration = True], which is a big handicap and renders using SetStopLoss the same as using the word "STOP".
It is posted in the thread which I referenced:Without seeing your code, the problem is still undetermined.
Code: Select all
SetStopContract ;
SetStopLoss(200) ;