Discussion about this post

User's avatar
new trader's avatar

Hi Peter,

coming from part 35, there is a correct math formula to calculate the adding size, I wrote my code by my own and tested hundreds of times and it's no problem. I did a careful look into your code, and found your math formula used a wrong variable and thus flawed. Since I'm not a subscriber I can't DM you, so I'll leave it here and hope you can see:

for example adding long position, the correct math using your way should be

{RISK - (CURRENT POS * AVG PRICE - CURRENT POS * YOUR_NEW_STOP_PRICE}/{CURRENT PRICE - NEW STOP}

the difference is this YOUR_NEW_STOP_PRICE part, and the hotkey shall work again. hope it helps!

Expand full comment
Berke's avatar

Long formula works perfectly. For short side I found that risk doubles everytime, I had declared custom name variables for other hotkeys maybe thats where my script is going wrong.

I added an if statement between

$TBR=$TBRLS-$TBRRS;

$TOP=$DRISK-$TBR;

these 2 lines.

if ($newstop>last)

{

$TBR=-$TBR;

}

I dont use this script to send orders but rather fill montage with correct order, now Im able to use same hotkey for both sides.

Thank you Peter most your free stuff was big help, free posts+das documentaion I was able to build custom scripts that only would be available through algo otherwise.

Expand full comment
28 more comments...

No posts