NexusFi: Find Your Edge


Home Menu

 





Creating a new function in Amibroker


Discussion in Platforms and Indicators

Updated
    1. trending_up 1,978 views
    2. thumb_up 2 thanks given
    3. group 2 followers
    1. forum 1 posts
    2. attach_file 0 attachments




 
Search this Thread

Creating a new function in Amibroker

  #1 (permalink)
milkysahai001
Agra+India
 
Posts: 42 since Sep 2016
Thanks Given: 17
Thanks Received: 3

i need to create a function MarketPosition in Amibroker, just like the one in MultiCharts. description in MultiCharts:
MarketPosition(N) returns whether the strategy is currently flat, short, or long on the current bar or for
N closed positions ago. MarketPosition return values are:
-1 for a short position.
1 for a long position.
0 for flat (no position).

I want to create same kind of function in Amibroker, but not good enough at coding.
Can somebody please help me do this.

Reply With Quote

Can you help answer these questions
from other members on NexusFi?
What broker to use for trading palladium futures
Commodities
NT7 Indicator Script Troubleshooting - Camarilla Pivots
NinjaTrader
How to apply profiles
Traders Hideout
MC PL editor upgrade
MultiCharts
REcommedations for programming help
Sierra Chart
 
  #2 (permalink)
alligator
paris france
 
Posts: 10 since Sep 2013
Thanks Given: 8
Thanks Received: 5

This thread is old, but it's a classic so I answer it as it could be useful for other people.

Use the Flip() function. In the following I assume you have defined your system using variables Buy/Sell/Short/Cover.
If one of them is not defined, assign 0 to it e.g if you have no short position:
 
Code
Short = Cover = 0; // no short positions

Now here's the solution to your problem:
 
Code
MarketPosition = Flip(Buy, Sell) - Flip(Short, Cover);

Yes, it's a one-liner, that's the magic of AFL.

Reply With Quote
Thanked by:




Last Updated on October 9, 2017


© 2024 NexusFi™, s.a., All Rights Reserved.
Av Ricardo J. Alfaro, Century Tower, Panama City, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada)
All information is for educational use only and is not investment advice. There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
About Us - Contact Us - Site Rules, Acceptable Use, and Terms and Conditions - Privacy Policy - Downloads - Top
no new posts