NexusFi: Find Your Edge


Home Menu

 





How to Backtest PriceAverage Crossove


Discussion in ThinkOrSwim

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




 
Search this Thread
  #1 (permalink)
apollo23
Singapore
 
Posts: 12 since Feb 2020
Thanks Given: 4
Thanks Received: 2

Hi

Found PriceAverageCrossover study in TOS but how do i simulate a buy and sell using this strategy? As it is, the Profit and Loss graph is not showing anything.

Am seeing the arrow signal on the chart but hope to improve it further. These are my thoughts.




Entry:

Previous Open of price must be below moving average and today open is above moving average

Exit Option 1:

Price close below moving average

Exit Option 2:

Price had increase say 30% from entry.

Can anybody help ? Below is the script:

 
Code
#
# TD Ameritrade IP Company, Inc. (c) 2009-2020
#

#wizard input: price
#wizard text: crosses
#wizard input: crossingType
#wizard input: averageType
#wizard text: Inputs: length:
#wizard input: length

input price = close;
input length = 15;
input averageType = AverageType.Simple;
input crossingType = {default above, below};

def avg = MovingAverage(averageType, price, length);

plot signal = crosses(price, avg, crossingType == CrossingType.above);

signal.DefineColor("Above", GetColor(6));
signal.DefineColor("Below", GetColor(7));
signal.AssignValueColor(if crossingType == CrossingType.above then signal.color("Above") else signal.color("Below"));

signal.SetPaintingStrategy(if crossingType == CrossingType.above
    then PaintingStrategy.BOOLEAN_ARROW_UP
    else PaintingStrategy.BOOLEAN_ARROW_DOWN);
Thanks


Reply With Quote

Can you help answer these questions
from other members on NexusFi?
UMA Votes Tonight: Polymarkets $80M Strategy Bitcoin Bat …
Prediction Markets & Event Contracts
Victory Day Delivers: Russia-Ukraine Ceasefire Market Cl …
Prediction Markets & Event Contracts
Irans Answer Due Today: Peace Surges to 33.5%, Invasion …
Prediction Markets & Event Contracts
CME Launches Bitcoin Volatility Futures June 1 -- First …
Cryptocurrency
Iran Talks Final Stages -- Two VLCCs Exit Hormuz, Record …
Traders Hideout
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
NexusFi site changelog and issues/problem reporting
15 thanks
Darmok and Jalad at Tanagra
3 thanks
Big Mike in Ecuador
1 thanks
30 Sessions
1 thanks
  #2 (permalink)
VanDriver
Jackson, MS
 
Posts: 34 since Dec 2015
Thanks Given: 1
Thanks Received: 5

The example you gave is of an indicator in the studies section. Studies only slow plots. Open the strategies section and modify the moving average crossover or similar strategy. Strategies will plot entry and exit signals. They will also show a p&l graph.


Reply With Quote




Last Updated on May 16, 2020


© 2026 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 - Downloads - Top
no new posts