sorry for my english
so,after 1 month I have still not set stoploss....
someone could really help me please?
and
the :intrabarordergeneration=I have to put it in ts in real time or in
backtest?
thanks
stop loss and IOG
- JoshM
- Posts: 2195
- Joined: 20 May 2011
- Location: The Netherlands
- Has thanked: 1544 times
- Been thanked: 1565 times
- Contact:
Re: stop loss and IOG
I assume your question is "How do I set a stop-loss in PowerLanguage?". Here's a rough programming example for that (see the comments for what part does what):sorry for my english
so,after 1 month I have still not set stoploss....
someone could really help me please?
Code: Select all
[IntrabarOrderGeneration = True];
Variables:
longStopPrice(0);
// Enter long
if (MarketPosition(0) = 0) then begin
longStopPrice = 0; // reset variable when flat
// Enter long at bar # 100 on bar close
if (BarStatus(1) = 2 and CurrentBar = 100) then begin
Buy ("EL") 1 contracts next bar at market;
// Set initial stoploss value
longStopPrice = Close * 0.99;
end;
end;
// Manage open long position
if (MarketPosition(0) > 0) then begin
// Update stoploss on bar close when there is a long position
if (BarStatus(1) = 2) then begin
longStopPrice = MaxList(longStopPrice, Close * 0.99);
end;
Sell ("SL XL") all contracts next bar at longStopPrice stop;
end;
Intra-bar order generation (IOG) can be used for both backtests and real-time trading. Generally speaking, if you use IOG for real-time trading, you should backtest with it too (and vice versa).and
the :intrabarordergeneration=I have to put it in ts in real time or in
backtest?
thanks
See the Bar Magnifier for how a backtest with IOG can be made more accurate.
- TJ
- Posts: 7743
- Joined: 29 Aug 2006
- Location: Global Citizen
- Has thanked: 1033 times
- Been thanked: 2222 times
Re: stop loss and IOG
There are 2 ways to make a stoploss...sorry for my english
so,after 1 month I have still not set stoploss....
someone could really help me please?
and
the :intrabarordergeneration=I have to put it in ts in real time or in
backtest?
thanks
1. MultiCharts' built-in Global Exits -- use the keyword SETSTOPLOSS. It is easy to implement, and meets 99% of the users' requirement.
2. You want your stop to be managed in your own specific way -- You have to design your logic, then write the code in EasyLanguage. If the logic is complex, you might have to hire a professional programmer to lay out the logic for you, before you can proceed to coding. Many logic may seem simple at a glance, but actually require lots of time and effort to hash out the sequences.
You have to first decide which method is best for your situation, then design a logic for your strategy.
Re: stop loss and IOG
thanks for advice.There are 2 ways to make a stoploss...sorry for my english
so,after 1 month I have still not set stoploss....
someone could really help me please?
and
the :intrabarordergeneration=I have to put it in ts in real time or in
backtest?
thanks
1. MultiCharts' built-in Global Exits -- use the keyword SETSTOPLOSS. It is easy to implement, and meets 99% of the users' requirement.
2. You want your stop to be managed in your own specific way -- You have to design your logic, then write the code in EasyLanguage. If the logic is complex, you might have to hire a professional programmer to lay out the logic for you, before you can proceed to coding. Many logic may seem simple at a glance, but actually require lots of time and effort to hash out the sequences.
Re: stop loss and IOG
josh I work in hotel.I assume your question is "How do I set a stop-loss in PowerLanguage?". Here's a rough programming example for that (see the comments for what part does what):sorry for my english
so,after 1 month I have still not set stoploss....
someone could really help me please?
Code: Select all
[IntrabarOrderGeneration = True];
Variables:
longStopPrice(0);
// Enter long
if (MarketPosition(0) = 0) then begin
longStopPrice = 0; // reset variable when flat
// Enter long at bar # 100 on bar close
if (BarStatus(1) = 2 and CurrentBar = 100) then begin
Buy ("EL") 1 contracts next bar at market;
// Set initial stoploss value
longStopPrice = Close * 0.99;
end;
end;
// Manage open long position
if (MarketPosition(0) > 0) then begin
// Update stoploss on bar close when there is a long position
if (BarStatus(1) = 2) then begin
longStopPrice = MaxList(longStopPrice, Close * 0.99);
end;
Sell ("SL XL") all contracts next bar at longStopPrice stop;
end;Intra-bar order generation (IOG) can be used for both backtests and real-time trading. Generally speaking, if you use IOG for real-time trading, you should backtest with it too (and vice versa).and
the :intrabarordergeneration=I have to put it in ts in real time or in
backtest?
thanks
See the Bar Magnifier for how a backtest with IOG can be made more accurate.
sorry everyone for disturb.
hapy new year to everyone
Re: stop loss and IOG
this is my TS;
Code: Select all
[LegacyColorValue = TRUE];
inputs:
ATRLength(2), ATRMult(2.1), UpColor(cyan), DnColor(magenta),TICKSAWAY(1);
vars:
ATR(0),
avg(0),
dn(0),
up(0),
trend(1),
flag(0),
flagh(0),
SuperTrend(0);
ATR = AvgTrueRange(ATRLength) * ATRMult;
avg = (high + low)/2;
up = avg + ATR;
dn = avg - ATR;
if close > up[1] then
trend = 1
else if close < dn[1] then
trend = -1;
if trend < 0 and trend[1] > 0 then flag=1 else flag=0;
if trend > 0 and trend[1] < 0 then flagh = 1 else flagh = 0;
if trend > 0 and dn < dn[1] then dn=dn[1];
if trend < 0 and up > up[1] then up=up[1];
if flag = 1 then up = avg + ATR;
if flagh = 1 then dn = avg - ATR;
if trend = 1 and trend [1] < 0 then buy 1000 shares next bar C+ 6*minmove/pricescale limit;
if trend = -1 and trend [1] >0 then Sellshort 1000 SHARES next bar C- 6*minmove/pricescale limit;