Rank: Advanced Member
Groups: Registered, Registered Users Joined: 3/19/2005(UTC) Posts: 2,995
Was thanked: 14 time(s) in 10 post(s)
|
Thanks for the suggestion, Jose. I tinkered with that thought, hence the line 'If(i6=3,plot,0)'. I just got near-sighted. Now, I'll eliminate that line and go with just a plain 'plot;0' instead. Thanks... I'm still in the back of the class. Hey, where's Patrick?! :lol:
[code:1:09a2e3de53]
{_g4_ProfitCalc v1.1, g_stockman, 2006}
{ user inputs }
i1:=Input("Share purchase price",0,1000,0);
i2:=Input("Number of shares purchased",0,50000,0);
i3:=Input("Brokerage Fee",0,25,8);
i4:=Input("Desired Profit %",0,100,7);
i5:=Input("StopLoss %",0,100,15);
i6:=Input("Plot: 1=$, 2=%, 3=signals",1,3,1);
{ p/l calculations }
CB:=(i1*i2)+i3;
PLD:=(C*i2)-cb;
PLP:=(PLD/CB)*100;
{ signals }
up:=If(PLP>=i4,1,0);
dn:=If(PLP<=-i5,-1,0);
{ plot }
plot:=
If(i6=1,PLD,
If(i6=2,PLP,
If(up=1 AND BarsSince(Ref(up, -1)) > 0,1,
If(dn=-1 AND BarsSince(Ref(dn, -1)) > 0,-1,0))));
0;plot
[/code:1:09a2e3de53]
Addendum:
re: zero reference avoidance- "It's probably better to place the zero plot before the plot line end, so that if the indicator gets referenced then it won't reference a zero value."
Also, changed that weird stoploss input.
|