Need Help Understanding ma_advisor

Section for discussions related to indicators, use of indicators, and building of trading stategies using indicators.

Moderator: admin

Need Help Understanding ma_advisor

Postby Jack68 » Fri Jun 14, 2013 12:15 pm

Hello Everyone
I am new here and new to LUA but am able to program in VB.net. I want to modify ma_advisor with some filters so am trying to understand it and learn LUA at the same time.

I plan to add some price based entry filters, delete the way it auto reverses the position when the crossover happens, and change the way the stop is moved. As it is it whipsaws during consolidation.

I cant find where a check for stop loss or target prices being hit is and I cant see where it moves the stoploss. I hope someone can give a brief explanation of how the stops and targets are managed.

For the trailing stop (long trades) my VB code is

If dayhigh(n) > countbackhigh Then 'we have a new high
countbackhigh = dayhigh(n)
countbacklow = daylow(n)
countcheck = 0
z = 0
Do Until countcheck = 2 'find the last 2 significant lows
If daylow(n - z) < countbacklow Then
countbacklow = daylow(n - z)
countcheck = countcheck + 1
End If
z = z + 1
Loop
If stoploss < countbacklow Then
stoploss = countbacklow
End If
End If

I think this should be easy to implement but I dont understand how the stop is currently moved and checked.

Thanks.
Jack68
 
Posts: 2
Joined: Fri Jun 14, 2013 10:07 am

Re: Need Help Understanding ma_advisor

Postby sunshine » Mon Jun 17, 2013 4:18 am

Hi Jack68,

I cant find where a check for stop loss or target prices being hit is and I cant see where it moves the stoploss.


The Stop/Limit orders are executed on the server. The server checks the Stop/Limit prices for each new tick and if the market price reaches the price of Stop or Limit, the position is closed. So, after the Stop/Limit orders are created, they will be executed automatically even if your strategy is paused or you are not logged in to the platform.

Regarding the moving of Stop/Limit prices. I think there are two options. You can either use the standard trailing options or move the prices within the strategy by your self.

In the first case, the order price will be adjusted automatically on the server in accordance with the trailing step that you specify: dynamic or fixed number of pips at your choice. For details, please check the value map for Stop/Limit orders in the documentation.

In the latter case, you should monitor the price for each new tick in the Update function and change the Stop/Limit prices if it's necessary. For example, please see Stage trailing stop strategy.

I hope it helps.
sunshine
 

Re: Need Help Understanding ma_advisor

Postby sunshine » Mon Jun 17, 2013 4:20 am

Also, the following thread may be helpful for you: Recommended reading.
sunshine
 

Using C extansion from Lua

Postby gidwayDomyday » Sun Jul 07, 2013 7:59 pm

rpgman

Thanks, my way works too Strange..

I would like to ask you a thing about lua function.

I've defined a lua function: local function Mainx, y return 1 end. After That I'll assign it to a another param:

sdk =

render_call_back = Main,


My question is that: is It possible to get the address to this function or it is created on fly? Can I use lua_tocfunction??

Thanks
User avatar
gidwayDomyday
 
Posts: 1
Joined: Thu Jun 20, 2013 7:20 pm
Location: Belgium


Return to Discussions

Who is online

Users browsing this forum: No registered users and 21 guests