How can I get the code of my statergy and backtest my statergy with amibroker and pi bridge?

Hellow,
I am new to alogo world and I have simple process which works on two different trading account and I want to know is my statergies are codable and if yes then I want to backtest this please help.
Let us assume stock name is ‘xyz’ and its initial cmp is Rs.1000 and total quantity of stock is 500.
STATERGY ‘A’ at 1st account:-(When stock moves up)
1-Buy 250 quantity of xyz at CMP(Initially it Rs.1000 as process continues it would be different).
2-Put trailing stoploss of Rs. 1.
3-If stoploss hits at a price lower than Buy price i.e.Rs. 999 and then after if stock moves up from stoploss hit price by Rs 1 i.e. stock price is now Rs. 1000 then again repeat step 1,2,3 and 4 same as above to continue this process.
4-If stoploss hits at a price higher than Buy price i.e. Rs. 1001 or 1002 or 1003etc. ,then as stoploss order executes again repeat step 1,2,3 and 4 to continue the process.

STATERGY ‘B’ at 2nd account:-(When stock moves down)
1-Shortsell 250 quantity of xyz at CMP (Initial Rs. 1000 as process continues it would be different).
2-Put trailing stoploss of Rs.1
3-If stoploss hits at a price higher than shortsell price i.e.Rs. 1001 and then after stock moves down from stoploss hit price by Rs 1 i.e. stock price is now Rs. 1000 then again repeat step 1,2,3 and 4 same as above and continue this process.
4-If stoploss hits at a price lower than shortsell price i.e. Rs. 999 or 998 or 997etc. ,then as stoploss order executes again repeat step 1,2,3 and 4 to continue the process.

The above condition can be possible with the Amibroker AFL but, its complex, also you have not mentioned on what basis you are taking the entry position and your conditions looks some thing continues orders execution in loop, reverify your condition again, you can contact some AFL Expert to make this task done with accuracy,

Also you have mentioned this condition with two different accounts with is not allowed or possible. i recommend to go with some advanced laguages like python if possible.

1 Like

Thank you very much sir,its really very helpful. Now where can I find AFL expert?And I have to take entry as market starts. And I can use two different pi trading account simulteneously then what problems occurs when I proceed like this? Please help.

you can login to pi with two client ids as pi supports multi user login but, here the problem is with amibroker connectivity, as you are using only one amibroker AFL running on your pc, if you connect with pi bridge as it is TCP connection it will connect to only one pi client id as TCP/IP connection through sockets is one to one.

Okay, then can I use the two different accounts for firing orders from Ami at same time with python? And if not then is there is any solution to done this job? Please help.