any help is deeply appreciated
if marketposition[1] =0 and C>highest(H,3) then buy next bar at market...
accurately code my idea that
if previous market position is zero then buy when current close exceed the high of last 3 trading bars?
i only want the signal to be "fired" if previous market position is zero. Is my code marketposition[1]
correct?
tks
how to code in powerlanguage to get previous market position
- TJ
- Posts: 7742
- Joined: 29 Aug 2006
- Location: Global Citizen
- Has thanked: 1033 times
- Been thanked: 2222 times
Re: how to code in powerlanguage to get previous market posi
Your code will never fire because C can never be higher than highest(H,3)... because it contains the current bar high.any help is deeply appreciated
if marketposition[1] =0 and C>highest(H,3) then buy next bar at market...
accurately code my idea that
if previous market position is zero then buy when current close exceed the high of last 3 trading bars?
i only want the signal to be "fired" if previous market position is zero. Is my code marketposition[1]
correct?
tks
You will need to compare the previous bars.
Code: Select all
C > highest(H,3)[1]
- JoshM
- Posts: 2195
- Joined: 20 May 2011
- Location: The Netherlands
- Has thanked: 1544 times
- Been thanked: 1565 times
- Contact:
Re: how to code in powerlanguage to get previous market posi
any help is deeply appreciated
if marketposition[1] =0 and C>highest(H,3) then buy next bar at market...
accurately code my idea that
if previous market position is zero then buy when current close exceed the high of last 3 trading bars?
i only want the signal to be "fired" if previous market position is zero. Is my code marketposition[1]
correct?
What TJ says, plus `MarketPosition` cannot be referenced for previous bars like `Close` and `High` can.Your code will never fire because C can never be higher than highest(H,3)... because it contains the current bar high.
But you can assign `MarketPosition` to a variable and then access the previous values for this values (meaning, the value the variable had on the close of the preceding bars).
If you understood you correctly, you'd get something like this:
Code: Select all
Variables:
highestHigh(0),
MP(0);
if (BarStatus(1) = 2) then begin
MP = MarketPosition;
highestHigh = Highest(High, 3)[1];
if (Close > highestHigh) and (MP[1] = 0) then
Buy next bar at market;
end;